package com.pym.service.impl;


import com.pym.common.ResultMsg;
import com.pym.dao.WpgjDao;
import com.pym.entity.PymWpgj;
import com.pym.service.WpgjService;
import com.pym.util.TypeToNameUtil;
import com.pym.util.pymUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Jerry
 * @Description //TODO 物品轨迹接口实现类
 * @Date 14:47 2021/8/19
 **/
@Service
public class WpgjServiceImpl implements WpgjService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WpgjDao wpgjDao;

    /**
     * @Author Jerry
     * @Description //TODO 根据物品ID查询物品轨迹接口
     * @Date 14:48 2021/8/19
     * @Param [id]
     * @return [java.lang.String]
     **/
    @Override
    public List<PymWpgj> queryWpgjByWpid(String wpId) {
        List<PymWpgj> pymWpgjList =  wpgjDao.queryWpgjByWpid(wpId);
        for (PymWpgj pymWpgj : pymWpgjList) {
            // 将状态值转换成状态名
            pymWpgj.setTypeName(TypeToNameUtil.getWpgjTypeName(pymWpgj.getType()));
        }
        return pymWpgjList;
    }

    @Override
    public int addWpgjBywzj(String wpbh, String exeOperStatus, String czrName, String orgName, String addTime) {
        return 1;//wpgjDao.queryWpgjByWpid(wpbh,exeOperStatus,czrName,orgName,addTime);
    }

    @Override
    public int addWpgjBywzj(PymWpgj pymWpgj) {
        // 生成随机字符串作为物品轨迹的主键ID
        String id = pymUtil.generateUUID();
        // 将id放入实体中
        pymWpgj.setId(id);
        return wpgjDao.insertWpgj(pymWpgj);
    }
}
